package net.alche.fa.core.doing;
import net.alche.fa.core.model.Logic;
import net.alche.fa.core.model.FaValue;
import net.alche.fa.core.CodeLevel;
import net.alche.fa.core.SageStone;
import net.alche.fa.core.FaException;
import net.alche.fa.core.FaClassConf;

// 静态对象
@FaAnnoDoing
public class FaStaDo extends AbstractDoing {

  @Override
  public boolean matched(String what, Logic g) {
    return "fm-sta".equals(what);
  }

  @Override
  public FaValue doing(Logic g, CodeLevel lvl, SageStone st) throws FaException {
    String pojoName = g.getObj();
    FaClassConf fcc = super.plat.getClassMap().get(pojoName);
    if (fcc == null) {
      return this.plat.getFaDo().getStaticObj(pojoName, lvl);
    }
    else {
      return new FaValue(fcc.getStaticSage());
    }
  }
}